package com.rookie.tool.module.util.sql;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author rookie
 */

@Getter
@AllArgsConstructor
public enum MysqlEnum {

    /**
     * 数据类型
     */
    BIG_INT("bigint", "Long"),

    BINARY("binary", "Byte[]"),

    BIT("bit", "Byte[]"),

    BLOB("blob", "Byte[]"),

    CHAR("char", "String"),

    DATE("date", "LocalDate"),

    DATE_TIME("datetime", "LocalDateTime"),

    DECIMAL("decimal", "BigDecimal"),

    DOUBLE("double", "BigDecimal"),

    ENUM("enum", "String"),

    FLOAT("float", "BigDecimal"),

    GEOMETRY("geometry", "Object"),

    GEOMETRY_COLLECTION("geometrycollection", "Object"),

    INT("int", "Integer"),

    INTEGER("integer", "Integer"),

    JSON("json", "Object"),

    LINESTRING("linestring", "Object"),

    LONGBLOB("longblob", "Byte[]"),

    LONGTEXT("longtext", "String"),

    MEDIUMBLOB("mediumblob", "Byte[]"),

    MEDIUMINT("mediumint", "Integer"),

    MEDIUMTEXT("mediumtext", "String"),

    MULTILINESTRING("multilinestring", "Object"),

    MULTIPOINT("multipoint", "Object"),

    MULTIPOLYGON("multipolygon", "Object"),

    NUMERIC("numeric", "BigDecimal"),

    POINT("point", "Object"),

    POLYGON("polygon", "Object"),

    REAL("real", "Object"),

    SET("set", "Object"),

    SMALLINT("smallint", "Integer"),

    TEXT("text", "String"),

    TIME("time", "LocalTime"),

    TIMESTAMP("timestamp", "LocalDateTime"),

    TINYBLOB("tinyblob", "Byte[]"),

    TINYINT("tinyint", "Integer"),

    TINYTEXT("tinytext", "String"),

    VARBINARY("varbinary", "Byte[]"),

    VARCHAR("varchar", "String"),

    YEAR("year", "Integer");


    private String item;

    private String beanItem;

    public static String getTypeOfJava(String type){
        for (MysqlEnum value : MysqlEnum.values()) {
            if (value.item.equals(type)){
                return value.beanItem;
            }
        }
        return null;
    }

    public static String getTypeOfSql(String type){
        for (MysqlEnum value : MysqlEnum.values()) {
            if (value.beanItem.equals(type)){
                return value.item;
            }
        }
        return null;
    }
}
